<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        #tab {
            margin: 0 auto;
            width: 700px;
            height: 500px;
            border: 1px solid black;
            text-align: center;

        }

        #tab td {

            border: 1px solid black;
            text-align: center;
            background-color: white;

        }

        #div1 {
            width: 150px;
            height: 50px;
            margin: 0 auto;
            text-align: center;
        }

        #span1 {
            display: block;
            margin: 0 auto;
            text-align: center;
        }
    </style>
    <script>
        var time = 0;
        var set;
        function fn() {
            time++;
            console.log(time);
            for (let i = 1; i <= 42; i++) {
                var obj = document.getElementById("td" + i);
                obj.style.backgroundColor = "white";
            }
            var num = Math.ceil(Math.random() * 42);
            var obj = document.getElementById("td" + num);
            obj.style.backgroundColor = "red";
            var spanObj = document.getElementById("span1")
            spanObj.innerText = "抽奖中......"
            console.log(num);
            if (time == 10) {
                spanObj = document.getElementById("span1")
                spanObj.innerText = "恭喜你，中奖了" + obj.innerText;
                clearInterval(set);
                time = 0;
            }
        }
        function start() {
            set = setInterval(fn, 100);
        }

        <!--------------------------------------------------------->
        function fn1() {
            time++;
            console.log(time);
            for (let i = 1; i <= 42; i++) {
                var obj = document.getElementById("td" + i);
                obj.style.backgroundColor = "white";
            }
            var num = Math.ceil(Math.random() * 42);

            var obj = document.getElementById("td" + num);
            obj.style.backgroundColor = "red";
            var spanObj = document.getElementById("span1")
            spanObj.innerText = "抽奖中......"
            console.log(num);
            if (time == 10) {
                obj.style.backgroundColor = "white";
                var obj1 = document.getElementById("td" + 35);
                console.log(obj1);
                spanObj = document.getElementById("span1")
                spanObj.innerText = "恭喜你，中奖了" + obj1.innerText;
                obj1.style.backgroundColor = "red";
                clearInterval(set);
                time = 0;
            }
        }
        function start1() {
            set = setInterval(fn1, 100);
        }

    </script>
</head>

<body>
    <div id="div1">
        <button id="but" onclick="start()">抽奖</button>
    </div>
    <span id="span1"></span>
    <table id="tab">
        <tr>
            <td id="td1">郑玮喆</td>
            <td id="td2">庄云</td>
            <td id="td3">廖治先</td>
            <td id="td4">郑文源</td>
            <td id="td5">戴俊锋</td>
        </tr>
        <tr>
            <td id="td6">陈昊童</td>
            <td id="td7">谢金金</td>
            <td id="td8">占志新</td>
            <td id="td9">张淑芳</td>
            <td id="td10">刘永潘</td>
        </tr>
        <tr>
            <td id="td11">廖柏成</td>
            <td id="td12">郑宗帅</td>
            <td id="td13">李韦峰</td>
            <td id="td14">吴欣燕</td>
            <td id="td15">陈梅香</td>
        </tr>
        <tr>
            <td id="td16">陈立智</td>
            <td id="td17">袁贵森</td>
            <td id="td18">赵浩敏</td>
            <td id="td19">林世涛</td>
            <td id="td20">罗启恒</td>
        </tr>
        <tr>
            <td id="td21">卢国建</td>
            <td id="td22">黄柱菘</td>
            <td id="td23">陈鹏</td>
            <td id="td24">张耀仁</td>
            <td id="td25">陈华伟</td>
        </tr>
        <tr>
            <td id="td26">张正豪</td>
            <td id="td27">韦仲晓</td>
            <td id="td28">黄富贵</td>
            <td id="td29">陆建锋</td>
            <td id="td30">曾德森</td>
        </tr>
        <tr>
            <td id="td31">吴文龙</td>
            <td id="td32">陆利群</td>
            <td id="td33">黄雄</td>
            <td id="td34">王世财</td>
            <td id="td35">张先杰</td>
        </tr>
        <tr>
            <td id="td36">胡基耀</td>
            <td id="td37">马鑫涛</td>
            <td id="td38">李涛</td>
            <td id="td39">杨凌翔</td>
            <td id="td40">罗此东</td>
        </tr>
        <tr>
            <td id="td41">唐皓颖</td>
            <td id="td42">白婉婷</td>

        </tr>
    </table>
</body>

</html>